<template>
	<view class="main u-page">
		<view class="head">
			<view class="head_box">
				<view class="tag_box">
					<view class="king_table">
						<text @click="operation(1)" :class="tableactive == 1 ? 'active' : 'inactive'">投递记录</text>
						<text @click="operation(2)" :class="tableactive == 2 ? 'active' : 'inactive'">邀请记录</text>
						<text @click="operation(3)" :class="tableactive == 3 ? 'active' : 'inactive'">浏览记录</text>
					</view>
				</view>
			</view>
		</view>
		<view class="main_content">
			<block v-for="(item,index) in list" v-if="list.length > 0">
				<view class="company_box">
					<block  v-if="tableactive < 3">
						<view style="display: flex;justify-content: space-between;">
							<view class="company_item_box" @click="goto('/resume/entdetails?id='+item.en_id)">
								<view class="company_name">
									{{item.ent_name}}
								</view>
								<view class="company_job" style="font-size: 32rpx;">
									<view style="margin-right: 20rpx;">{{item.position || ''}}</view>·
									<view style="margin-left: 20rpx;">{{item.salary_low || ''}}-{{item.salary_hei || ''}}</view>
								</view>
								<view class="company_job">地址：{{item.address || ''}}</view>
								<view class="company_job">技能：{{item.skill || ''}}</view>
								<view class="company_job" v-if="item.create_time">时间：{{item.create_time || ''}}</view>
								<view class="company_job">
									状态：{{item.status==1 ? '待面试' : item.status==2 ? '已面试' : item.status==3 ? '已取消' : item.status==0 ? '待处理' : '已拒绝'}}
								</view>
								<view class="company_job" v-if="item.status==1">面试时间：{{item.interview_time}}</view>
							</view>
							<view class="company_logo">
								<view class="company_logo_item">
									<image :src="imgURL + item.logo"></image>
								</view>
								<view v-if="tableactive == 1" class="jsob_yao_item" @click="quxiaodelivery(item.id)">取消申请</view>
								<view v-if="tableactive == 2" style="display: flex;justify-content: space-between;">
									<view class="jsob_yao_item" @click="handleInvitation(item.id,1)">
										接受
									</view>
									<view class="jsob_yao_item" style="background-color: #999;" @click="handleInvitation(item.id,3)">
										拒绝
									</view>
								</view>
							</view>
						</view>
					</block>
					<block  v-else>
						<view style="display: flex;justify-content: space-between;">
							<view class="company_item_box"  style="width: 500rpx;" @click="goto('/resume/entdetails?id='+item.ent_id)">
								<view class="company_name">
									{{item.ent_name}}
								</view>
								<view class="company_job">地址：{{item.address || ''}}</view>
								<view class="company_job">领域：{{item.fieldname || ''}} · {{item.scale || ''}}</view>
							</view>
							<view class="company_logo" style="width: 120rpx;">
								<view class="company_logo_item">
									<image :src="imgURL + item.logo"></image>
								</view>
							</view>
						</view>
						<view class="company_job" v-if="tableactive == 3">
							福利：{{item.remark || ''}}
						</view>
					</block>
				</view>
			</block>
			<block v-else>
			<u-empty mode="data"> </u-empty>
			</block>
		</view>
		<Tabbar :count="100"></Tabbar>
	</view>
</template>

<script>
	import Tabbar from "@/components/Tabbar"
	import { formatTime } from '@/utils/utils'
	import { imgURL } from '@/utils/config'
	import { getPositionList } from '@/api/position.js'
	import { quxiaodelivery,getdelivery,getView,getinvitation,handleInvitation } from '@/api/user.js'
	
	export default {
		components: {
			Tabbar
		},
		data() {
			return {
				tableactive:1,
				imgURL:imgURL,
				yaoqingModal:false,
				showposition:false,
				timeshow:false,
				list: [],
				label:['应届生','就职人才'],
				form:{
					page:1,
					pagesize:20,
					total:0,
					keyword:'',
				},
				yaoqingform:{
					uid:'',
					position_id:'',
					position_name:'',
					interview_time:'',
					interview_date:''
				}
			}
		},
		onLoad() {
			this.getdeliveryList()
		},
		methods: {
			operation(tableactive){
				this.form = {
					page:1,
					pagesize:10,
					total:0,
					keyword:'',
				}
				this.tableactive = tableactive
				switch(tableactive){
					case 1:
						this.getdeliveryList()
						break;
					case 2:
						this.getinvitationList()
						break;
					default:
						this.getViewList()
						break;
				}
			},
			
			//获取投递信息
			getdeliveryList() {
				getdelivery(this.form).then(res=>{
					if(res.code == 200){
						this.list = res.data.data
						this.form.total = res.data.total
					}
					else{
						return uni.showToast({
							icon: 'none',
							title: res.msg
						});
					}
				})
			},
			
			//获取邀请信息
			getinvitationList() {
				getinvitation(this.form).then(res=>{
					if(res.code == 200){
						this.list = res.data.data
						this.form.total = res.data.total
					}
					else{
						return uni.showToast({
							icon: 'none',
							title: res.msg
						});
					}
				})
			},
			
			//获取浏览信息
			getViewList() {
				getView(this.form).then(res=>{
					if(res.code == 200){
						this.list = res.data.data
						this.form.total = res.data.total
					}
					else{
						return uni.showToast({
							icon: 'none',
							title: res.msg
						});
					}
				})
			},
			
			//取消投递
			quxiaodelivery(id) {
				quxiaodelivery({id:id}).then(res=>{
						uni.showToast({
							icon: 'none',
							title: res.msg
						});
				})
			},
			
			//操作邀请
			handleInvitation(id,status){
				handleInvitation({id:id,status:status}).then(res=>{
						uni.showToast({
							icon: 'none',
							title: res.msg
						});
				})
			},
			
			goto(tourl) {
				uni.navigateTo({
					url: tourl
				});
			}
			
		},
	}
</script>

<style lang="scss">
	.head{
		background-image: url('');
		background-repeat:no-repeat;
		background-attachment:fixed;
		background-size:cover;
		width: 100%;
		height: 420rpx;
		display: block;
		image{
			width: 100%;
			height: 100%;
		}
		.head_box{
			padding-top: 30rpx;
			width: 100%;
			.job_box{
				margin: 0 40rpx;
				height: 100rpx;
				line-height: 100rpx;
				text-align: center;
				font-size: 48rpx;
				color: #fff;
				text{
					color: #43e4f8;
				}
			}
			.tag_box{
				margin: 0 60rpx;
				height:80rpx;
				line-height: 80rpx;
				color: #fff;
				font-size: 26rpx;
				.king_table{
					margin: 90rpx 0rpx;
					.inactive{
						border: 1px solid #f4f4f4;
						padding: 16rpx 40rpx;
						color: #fff;
						margin-right: 20rpx;
					}
					.active{
						margin-right: 20rpx;
						border: 1px solid #989dfd;
						background-color: #989dfd;
						padding: 16rpx 40rpx;
						color: #fff;
					}
				}
			}
		}
	}
	.main_content{
		margin-top: -200rpx;
		.company_box{
			background-color: #f9f9f9;
			display: flex;
			flex-wrap: wrap;
			margin: 20rpx 40rpx;
			padding: 20rpx 40rpx;
			font-size: 24rpx;
			color: #000;
			.company_logo{
				display: flex;
				flex-wrap: wrap;
				justify-content: center;
				align-items: center;
				.jsob_yao_item{
					border: 1px solid #f3f3f3;
					background-color: #989dfd;
					color: #fff;
					font-size: 28rpx;
					margin-top: 20rpx;
					padding: 10rpx;
					width: 100%;
					text-align: center;
				}
				.company_logo_item{
					width:100rpx; 
					height:100rpx;
					border: #fcfcfc 5px solid;
					image{
						max-width: 100% !important;
						max-height: 100% !important;
					}
				}
			}
			.company_item_box{
				width: 430rpx;
				.company_name{
					width: 100%;
					font-size: 30rpx;
					height: 50rpx;
					line-height: 50rpx;
					white-space:nowrap;
					overflow:hidden;
					text-overflow:ellipsis;
				}
				.company_handle{
					margin: 20rpx;
					.handle_shenqin{
						width: 200rpx;
						line-height: 80rpx;
					}
				}
				
				.company_job,.company_addr,.company_salary{
					display: flex;
					align-items: center;
					font-size: 28rpx;
					height: 50rpx;
					width: 100%;
					white-space:nowrap;
					overflow:hidden;
					text-overflow:ellipsis;
				}
				.company_intro{
					line-height: 50rpx;
					color: #777777;
					margin-bottom: 20rpx;
				}
			}
		}
	}
	.foot{
		background-color: #000;
	}
</style>